package com.aaa.controller;

import com.aaa.entity.Menu;
import com.aaa.entity.Users;
import com.aaa.service.MenuService;
import com.aaa.util.DefaultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LoginController {
    @Autowired
    private MenuService menuService;
    /**
     * 退出登录之后调用的路径
     * @return
     */
    @RequestMapping("/logoutSuccess")
    public DefaultMsg logoutSuccess(){
        DefaultMsg defaultMsg=new DefaultMsg();
        return defaultMsg;
    }
    /**
     * 跳转到主界面
     */
    @PostMapping("/listMyMenus")
    public List<Menu> listMyMenus(Authentication authentication){
        Users principal=(Users) authentication.getPrincipal();
        //把用户能操作的所有菜单查询出来 传递到界面上
        List<Menu> menus=menuService.listMyMenus(principal.getUid());
        return menus;
    }
}
